# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=python-objgraph
pkgver=3.5.0
pkgrel=8
pkgdesc="Draws Python object reference graphs with graphviz"
url="https://github.com/mgedmin/objgraph"
license=('MIT')
arch=('any')
depends=('python')
makedepends=('python-setuptools')
checkdepends=('graphviz')
source=("objgraph-$pkgver.tar.gz::https://github.com/mgedmin/objgraph/archive/$pkgver.tar.gz"
        'objgraph-py311.patch::https://github.com/mgedmin/objgraph/commit/f4023026878c8ab20695acc09a5e83ec9aff91ef.patch')
sha512sums=('50bf1967d6696547598628d49f3c827f1535d6de032fb429881e523f144bb57e128d09f43d280b89a0f9205ca97ef10331e0da1dc86637af0214bfd7aa4cba3b'
            '537a2b94ffd9465951518518d796ad8c914580ddbf6efc10d48101c7f4b9827789dc95e9a72b7af62994ae02676d49b82c2634b748c1c22e33d47b537595b83c')

prepare() {
  cd objgraph-$pkgver
  # Only for ipython support
  sed -i "/'graphviz'/d" setup.py

  patch --forward --strip=1 --input=../objgraph-py311.patch || true
}

build() {
  cd objgraph-$pkgver
  python setup.py build
}

check() {
  cd objgraph-$pkgver
  python setup.py test
}

package() {
  cd objgraph-$pkgver
  python setup.py install --root="$pkgdir" --optimize=1
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
